require 'sinatra'
require_relative'../lib/aboutyou-sdk.rb'

get "/doCache" do
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Redis.new(Redis.new))
  shop.fetch_products_by_ids([661132, 660971, 661367, 661361], [AboutYou::SDK::Criteria::ProductFields::CATEGORIES])
end

get "/getCache" do
  result = ""
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Redis.new(Redis.new))
  
  shop.fetch_category_tree.categories.each do |key, cate|
    result = result + cate.name + '  '
  end
  
  return result
end

get "/noCache" do
  result = ""
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Redis.new(Redis.new))
  shop.cache.delete('AY:SDK:281:categories')
  
  shop.fetch_category_tree.categories.each do |key, cate|
    result = result + cate.name + '  '
  end
  
  return result
end